package com.xmx.controller;

import com.xmx.entity.Chances;
import com.xmx.service.IChancesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

/**
 * 描述：
 * 作者：bihui
 * 时间：2023年04月24日 16:45
 */
@Controller
@RequestMapping("/page_Sale")
public class ChancesController {
    @Autowired
    private IChancesService iChancesService;

    //查询所有销售机会信息
    @RequestMapping("queryChances")
    public String queryChances(Map map){
        List<Chances> chancesList = iChancesService.queryChances();
        map.put("chancesList",chancesList);
        System.out.println(chancesList);
        return "Sale/SaleChance";
    }
    //根据id查询销售机会信息
    @RequestMapping("queryChancesById")
    public String queryChancesById(int id,Map map){
        Chances chances = iChancesService.queryChancesById(id);
        map.put("chances",chances);
        return "Sale/EditSale";
    }

    //修改销售机会信息
    @PostMapping("updateChances")
    public String updateChances(Chances chances){
        iChancesService.updateChances(chances);
        System.out.println(chances+"-------------------------");
        return "redirect:queryChances";
    }
}
